home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-10-12 | 12.5 KB | 345 lines | [TEXT/PJMM] |
- unit TextServices;
-
- { Pascal Interface to the Macintosh Libraries }
-
- { Copyright © Apple Computer Inc. }
- { All Rights Reserved }
-
- { Adapted for use with THINK Pascal 4.0.x by Marco Piovanelli }
-
- interface
- uses
- AppleEvents, Components;
-
- const
-
- { TSM gestalt constants (!!! transplanted from GestaltEqu.p !!!) }
-
- gestaltTSMgrVersion = 'tsmv';
-
- gestaltTSMgrAttr = 'tsma'; { Text Services Mgr attributes, if present }
- gestaltTSMDisplayMgrAwareBit = 0; { TSM knows about display manager }
-
- { TSM errors (!!! transplanted from Errors.p !!!) }
-
- tsmComponentNoErr = 0; { component result = no error }
- tsmUnsupScriptLanguageErr = -2500;
- tsmInputMethodNotFoundErr = -2501;
- tsmNotAnAppErr = -2502; { not an application error }
- tsmAlreadyRegisteredErr = -2503; { want to register again error }
- tsmNeverRegisteredErr = -2504; { app never registered error (not TSM aware) }
- tsmInvalidDocIDErr = -2505; { invalid TSM documentation id }
- tsmTSMDocBusyErr = -2506; { document is still active }
- tsmDocNotActiveErr = -2507; { document is NOT active }
- tsmNoOpenTSErr = -2508; { no open text service }
- tsmCantOpenComponentErr = -2509; { can’t open the component }
- tsmTextServiceNotFoundErr = -2510; { no text service found }
- tsmDocumentOpenErr = -2511; { there are open documents }
- tsmUseInputWindowErr = -2512; { not TSM aware because we are using input window }
- tsmTSHasNoMenuErr = -2513; { the text service has no menu }
- tsmTSNotOpenErr = -2514; { text service is not open }
- tsmComponentAlreadyOpenErr = -2515; { text service already opened for the document }
- tsmInputMethodIsOldErr = -2516; { returned by GetDefaultInputMethod }
- tsmScriptHasNoIMErr = -2517; { script has no imput method or is using old IM }
- tsmUnsupportedTypeErr = -2518; { unSupported interface type error }
- tsmUnknownErr = -2519; { any other errors }
-
- { AppleEvent error definitions (!!! transplanted from Errors.p !!!) }
- errOffsetInvalid = -1800;
- errOffsetIsOutsideOfView = -1801;
- errTopOfDocument = -1810;
- errTopOfBody = -1811;
- errEndOfDocument = -1812;
- errEndOfBody = -1813;
-
-
- kTSMVersion = $200; { Version of the Text Services Manager is 2.0 }
- kTextService = 'tsvc'; { component type for the component description }
- kInputMethodService = 'inpm'; { component subtype for the component description }
-
- { Component Flags in ComponentDescription }
- bTakeActiveEvent = 15; { bit set if the component takes active event }
- bHandleAERecording = 16; { bit set if the component takes care of recording Apple Events <new in vers2.0> }
- bScriptMask = $00007F00; { bit 8 - 14 }
- bLanguageMask = $000000FF; { bit 0 - 7 }
- bScriptLanguageMask = bScriptMask + bLanguageMask; { bit 0 - 14 }
-
- { Hilite styles }
- kCaretPosition = 1; { specify caret position }
- kRawText = 2; { specify range of raw text }
- kSelectedRawText = 3; { specify range of selected raw text }
- kConvertedText = 4; { specify range of converted text }
- kSelectedConvertedText = 5; { specify range of selected converted text }
-
- { Apple Event constants }
- { Event class }
- kTextServiceClass = kTextService;
- { event ID }
- kUpdateActiveInputArea = 'updt'; { update the active Inline area }
- kPos2Offset = 'p2st'; { converting global coordinates to char position }
- kOffset2Pos = 'st2p'; { converting char position to global coordinates }
- kShowHideInputWindow = 'shiw'; { show or hide the input window }
- { Event keywords }
- keyAETSMDocumentRefcon = 'refc'; { TSM document refcon, typeLongInteger }
- { Note: keyAETSMScriptTag, keyAERequestedType, keyAETSMTextFont, keyAETextPointSize}
- { typeAEText, typeIntlWritingCode, typeQDPoint, and keyAEAngle have been moved to }
- { AERegistry.h }
- keyAEServerInstance = 'srvi'; { component instance }
- keyAETheData = 'kdat'; { typeText }
- keyAEFixLength = 'fixl'; { fix len ?? }
- keyAEHiliteRange = 'hrng'; { hilite range array }
- keyAEUpdateRange = 'udng'; { update range array }
- keyAEClauseOffsets = 'clau'; { Clause Offsets array }
- keyAECurrentPoint = 'cpos'; { current point }
- keyAEDragging = 'bool'; { dragging falg }
- keyAEOffset = 'ofst'; { offset }
- keyAERegionClass = 'rgnc'; { region class }
- keyAEPoint = 'gpos'; { current point }
- keyAEBufferSize = 'buff'; { buffer size to get the text }
- keyAEMoveView = 'mvvw'; { move view flag }
- keyAELength = 'leng'; { length }
- keyAENextBody = 'nxbd'; { next or previous body }
- { optional keywords for Offset2Pos (Info about the active input area) }
- keyAETextLineHeight = 'ktlh'; { typeShortInteger }
- keyAETextLineAscent = 'ktas'; { typeShortInteger }
- { optional keywords for Pos2Offset }
- keyAELeftSide = 'klef'; { type Boolean }
- { optional keywords for kShowHideInputWindow }
- keyAEShowHideInputWindow = 'shiw'; { type Boolean }
- { for PinRange }
- keyAEPinRange = 'pnrg';
- { Desc type ... }
- typeComponentInstance = 'cmpi'; { server instance }
- typeTextRangeArray = 'tray'; { text range array }
- typeOffsetArray = 'ofay'; { offset array }
- typeText = 'TEXT'; { Plain text }
- typeTextRange = 'txrn';
-
- { Desc type constants }
- kTSMOutsideOfBody = 1;
- kTSMInsideOfBody = 2;
- kTSMInsideOfActiveInputArea = 3;
-
- kNextBody = 1;
- kPreviousBody = 2;
-
- { typeTextRange 'txrn' }
-
- type
- TextRange = record
- fStart: LONGINT;
- fEnd: LONGINT;
- fHiliteStyle: INTEGER;
- end;
- TextRangePtr = ^TextRange;
-
- TextRangeHandle = ^TextRangePtr;
-
- { typeTextRangeArray 'txra' }
- TextRangeArray = record
- fNumOfRanges: INTEGER; { specify the size of the fRange array }
- fRange: array[0..0] of TextRange; { when fNumOfRanges > 1, the size of this array has to be calculated }
- end;
- TextRangeArrayPtr = ^TextRangeArray;
-
- TextRangeArrayHandle = ^TextRangeArrayPtr;
-
- { typeOffsetArray 'offa' }
- OffsetArray = record
- fNumOfOffsets: INTEGER; { specify the size of the fOffset array }
- fOffset: array[0..0] of LONGINT; { when fNumOfOffsets > 1, the size of this array has to be calculated }
- end;
- OffsetArrayPtr = ^OffsetArray;
-
- OffsetArrayHandle = ^OffsetArrayPtr;
-
- TSMDocumentID = Ptr;
-
- InterfaceTypeList = array[0..0] of OSType;
-
- { Text Service Info List }
- TextServiceInfo = record
- fComponent: Component;
- fItemName: Str255;
- end;
- TextServiceInfoPtr = ^TextServiceInfo;
-
- TextServiceList = record
- fTextServiceCount: INTEGER; { number of entries in the 'fServices' array }
- fServices: array[0..0] of TextServiceInfo; { Note: array of 'TextServiceInfo' records follows }
- end;
- TextServiceListPtr = ^TextServiceList;
-
- TextServiceListHandle = ^TextServiceListPtr;
-
- ScriptLanguageRecord = record
- fScript: ScriptCode;
- fLanguage: LangCode;
- end;
- ScriptLanguageSupport = record
- fScriptLanguageCount: INTEGER; { number of entries in the 'fScriptLanguageArray' array }
- fScriptLanguageArray: array[0..0] of ScriptLanguageRecord; { Note: array of 'ScriptLanguageRecord' records follows }
- end;
- ScriptLanguageSupportPtr = ^ScriptLanguageSupport;
-
- ScriptLanguageSupportHandle = ^ScriptLanguageSupportPtr;
-
-
- const
- { Low level routines which are dispatched directly to the Component Manager }
- kCMGetScriptLangSupport = $0001; { Component Manager call selector 1 }
- kCMInitiateTextService = $0002; { Component Manager call selector 2 }
- kCMTerminateTextService = $0003; { Component Manager call selector 3 }
- kCMActivateTextService = $0004; { Component Manager call selector 4 }
- kCMDeactivateTextService = $0005; { Component Manager call selector 5 }
- kCMTextServiceEvent = $0006; { Component Manager call selector 6 }
- kCMGetTextServiceMenu = $0007; { Component Manager call selector 7 }
- kCMTextServiceMenuSelect = $0008; { Component Manager call selector 8 }
- kCMFixTextService = $0009; { Component Manager call selector 9 }
- kCMSetTextServiceCursor = $000A; { Component Manager call selector 10 }
- kCMHidePaletteWindows = $000B; { Component Manager call selector 11 }
-
- { High level TSM routines }
-
- function NewTSMDocument (numOfInterface: INTEGER;
- var supportedInterfaceTypes: InterfaceTypeList;
- var idocID: TSMDocumentID;
- refcon: LONGINT): OSErr;
- inline
- $7000, $AA54;
- function DeleteTSMDocument (idocID: TSMDocumentID): OSErr;
- inline
- $7001, $AA54;
- function ActivateTSMDocument (idocID: TSMDocumentID): OSErr;
- inline
- $7002, $AA54;
- function DeactivateTSMDocument (idocID: TSMDocumentID): OSErr;
- inline
- $7003, $AA54;
- function TSMEvent (var event: EventRecord): BOOLEAN;
- inline
- $7004, $AA54;
- function TSMMenuSelect (menuResult: LONGINT): BOOLEAN;
- inline
- $7005, $AA54;
- function SetTSMCursor (mousePos: Point): BOOLEAN;
- inline
- $7006, $AA54;
- function FixTSMDocument (idocID: TSMDocumentID): OSErr;
- inline
- $7007, $AA54;
- function GetServiceList (numOfInterface: INTEGER;
- var supportedInterfaceTypes: OSType;
- var serviceInfo: TextServiceListHandle;
- var seedValue: LONGINT): OSErr;
- inline
- $7008, $AA54;
- function OpenTextService (idocID: TSMDocumentID;
- aComponent: Component;
- var aComponentInstance: ComponentInstance): OSErr;
- inline
- $7009, $AA54;
- function CloseTextService (idocID: TSMDocumentID;
- aComponentInstance: ComponentInstance): OSErr;
- inline
- $700A, $AA54;
- function SendAEFromTSMComponent ({CONST}
- var theAppleEvent: AppleEvent;
- var reply: AppleEvent;
- sendMode: AESendMode;
- sendPriority: AESendPriority;
- timeOutInTicks: LONGINT;
- idleProc: AEIdleUPP;
- filterProc: AEFilterUPP): OSErr;
- inline
- $700B, $AA54;
- function InitTSMAwareApplication: OSErr;
- inline
- $7014, $AA54;
- function CloseTSMAwareApplication: OSErr;
- inline
- $7015, $AA54;
- { Utilities }
- function SetDefaultInputMethod (ts: Component;
- var slRecordPtr: ScriptLanguageRecord): OSErr;
- inline
- $700C, $AA54;
- function GetDefaultInputMethod (var ts: Component;
- var slRecordPtr: ScriptLanguageRecord): OSErr;
- inline
- $700D, $AA54;
- function SetTextServiceLanguage (var slRecordPtr: ScriptLanguageRecord): OSErr;
- inline
- $700E, $AA54;
- function GetTextServiceLanguage (var slRecordPtr: ScriptLanguageRecord): OSErr;
- inline
- $700F, $AA54;
- function UseInputWindow (idocID: TSMDocumentID;
- useWindow: BOOLEAN): OSErr;
- inline
- $7010, $AA54;
- function NewServiceWindow (wStorage: univ Ptr; {CONST}
- var boundsRect: Rect;
- title: ConstStr255Param;
- visible: BOOLEAN;
- theProc: INTEGER;
- behind: WindowPtr;
- goAwayFlag: BOOLEAN;
- ts: ComponentInstance;
- var window: WindowPtr): OSErr;
- inline
- $7011, $AA54;
- function CloseServiceWindow (window: WindowPtr): OSErr;
- inline
- $7012, $AA54;
- function GetFrontServiceWindow (var window: WindowPtr): OSErr;
- inline
- $7013, $AA54;
- function FindServiceWindow (thePoint: Point;
- var theWindow: WindowPtr): INTEGER;
- inline
- $7017, $AA54;
- { Low level TSM routines }
- function GetScriptLanguageSupport (ts: ComponentInstance;
- var scriptHdl: ScriptLanguageSupportHandle): ComponentResult;
- inline
- $2F3C, $04, $0001, $7000, $A82A;
- function InitiateTextService (ts: ComponentInstance): ComponentResult;
- inline
- $2F3C, $00, $0002, $7000, $A82A;
- function TerminateTextService (ts: ComponentInstance): ComponentResult;
- inline
- $2F3C, $00, $0003, $7000, $A82A;
- function ActivateTextService (ts: ComponentInstance): ComponentResult;
- inline
- $2F3C, $00, $0004, $7000, $A82A;
- function DeactivateTextService (ts: ComponentInstance): ComponentResult;
- inline
- $2F3C, $00, $0005, $7000, $A82A;
- function TextServiceEvent (ts: ComponentInstance;
- numOfEvents: INTEGER;
- var event: EventRecord): ComponentResult;
- inline
- $2F3C, $06, $0006, $7000, $A82A;
- function GetTextServiceMenu (ts: ComponentInstance;
- var serviceMenu: MenuHandle): ComponentResult;
- inline
- $2F3C, $4, $0007, $7000, $A82A;
- function TextServiceMenuSelect (ts: ComponentInstance;
- serviceMenu: MenuHandle;
- item: INTEGER): ComponentResult;
- inline
- $2F3C, $06, $0008, $7000, $A82A;
- function FixTextService (ts: ComponentInstance): ComponentResult;
- inline
- $2F3C, $00, $0009, $7000, $A82A;
- function SetTextServiceCursor (ts: ComponentInstance;
- mousePos: Point): ComponentResult;
- inline
- $2F3C, $04, $000A, $7000, $A82A;
- function HidePaletteWindows (ts: ComponentInstance): ComponentResult;
- inline
- $2F3C, $00, $000B, $7000, $A82A;
-
- implementation
- end.